//
//  QuoteOperTools.m
//  Stock_Pro_ax
//
//  Created by gaotime on 16/2/23.
//  Copyright © 2016年 gaotime. All rights reserved.
//

#import "QuoteOperTools.h"
#import "FileTools.h"
#import "QuoteLvOper.h"
#import "JSONKit.h"

@implementation QuoteOperTools

+(BOOL)IsRStock:(QUOTELV_OPER *)aOper withCode:(char*)aCode withMacket:(char)aMacketId{
  BOOL bRet;
  bRet = FALSE;
  
  FILE_DATA* f_data = FileTools_ReadDataEx(aOper->pBDZQPath);
  
  if (f_data && f_data->nSize <= 0) {
    return bRet;
  }
  
  NSString *source = [[NSString alloc] initWithBytes:f_data->pData length:f_data->nSize encoding:NSUTF8StringEncoding];
  
  NSDictionary *pDic = [source objectFromJSONString];
  if (aMacketId == '\x01') {
    NSDictionary *pReturnDic = [pDic objectForKey:@"1"];
    
    NSString *code = [[NSString alloc] initWithBytes:aCode length:strlen(aCode) encoding:NSUTF8StringEncoding];
    if([[pReturnDic allKeys] containsObject:code]){
      // key存在
      bRet = TRUE;
    }
  }else if(aMacketId == '\x02'){
    NSDictionary *pReturnDic = [pDic objectForKey:@"2"];
    
    NSString *code = [[NSString alloc] initWithBytes:aCode length:strlen(aCode) encoding:NSUTF8StringEncoding];
    if([[pReturnDic allKeys] containsObject:code]){
      // key存在
      bRet = TRUE;
    }
  }
  
  return bRet;
}

@end
